import React, {useEffect, useState} from 'react';
import {ProColumns} from '@ant-design/pro-table';
import {Dict} from './data.d';
import {modulesUrl} from "@/assets/constant/modulesUrl";
import TableList from "@/assets/components/tableList";
import {hooksSet} from "@/assets/utils/utils";
import {Form} from "antd";

const DictList: React.FC<{}> = () => {
  const [form] = Form.useForm();

  const [columns, setColumns] = useState<ProColumns<Dict>[]>([
    {
      title: '标签',
      dataIndex: 'label',
      formItemProps: {
        rules: [
          {
            required: true,
            message: '名称为必填项',
          },
        ],
      },
    },
    {
      title: '标签值',
      dataIndex: 'value',
      hideInSearch: true,
      formItemProps: {
        rules: [
          {
            required: true,
            message: '标签值为必填项',
          },
        ],
      },
    },
    {
      title: '类型',
      dataIndex: 'type',
      formItemProps: {
        rules: [
          {
            required: true,
            message: '类型为必填项',
          },
        ],
      },
    },
    {
      title: '描述',
      dataIndex: 'description',
      valueType: "textarea"
    },
  ]);

  useEffect(() => {

  }, []);

  return (
    <TableList
      form={form}
      changeColumns={(columns: any) => hooksSet(setColumns, columns)}
      columns={columns}
      moduleUrl={modulesUrl.sysDict} title={"字典管理"}
      isFindPage={true}
    />
  );
};

export default DictList;
